package com.jubaozan.service.platform.controller.admin;

import com.jubaozan.c3.framework.constants.Constants;
import com.jubaozan.c3.framework.utils.ResultHolder;
import com.jubaozan.dao.youme.domain.StoreAudit;
import com.jubaozan.service.platform.decorator.PlatformAuditDecorator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName PlatformAuditController
 * @Description 个体平台入驻审核相关接口Controller
 * @Author SunWei
 * @Version 1.0
 **/
@Api(tags = {"个体平台入驻审核相关接口"}, value = "个体平台入驻审核相关接口")
@RestController
@RequestMapping("/admin/audit")
@Validated
public class PlatformAuditController {

    private final PlatformAuditDecorator platformAuditDecorator;

    public PlatformAuditController(PlatformAuditDecorator platformAuditDecorator) {
        this.platformAuditDecorator = platformAuditDecorator;
    }


    @ApiOperation(value = "平台入驻申请通过")
    @PutMapping("/pass")
    public ResultHolder<Object> pass(@RequestHeader(Constants.KEY_X_C3_USERNAME) String username,
                                    @ApiParam(value = "是否需要复审(企业平台需要传此参数)",example = "false") Boolean reviewStatus,
                                     @ApiParam(value = "审核原因对象") StoreAudit storeAudit) {
        //审核人
        storeAudit.setAuditBy(username);
        return ResultHolder.success(platformAuditDecorator.pass(reviewStatus,storeAudit));
    }

    @ApiOperation(value = "平台入驻申请拒接")
    @PutMapping("/refuse")
    public ResultHolder<Object> refuse(@RequestHeader(Constants.KEY_X_C3_USERNAME) String username,@ApiParam(value = "审核原因对象") StoreAudit storeAudit) {
        //审核人
        storeAudit.setAuditBy(username);
        return ResultHolder.success(platformAuditDecorator.refuse(storeAudit));
    }


}
